<?php

/**
 * XHTML document, head
 * 
 * @package Core
 * @subpackage Document
 *
 */
class Lead_Controller_Response_Document_Head extends Lead_Controller_Response_Document_Part
{
	/**
	 * Document Head Meta
	 *
	 * @var Document_Head_Meta
	 */
	public $meta;
	/**
	 * Document Head Style
	 *
	 * @var Document_Head_Style
	 */
	public $style;
	/**
	 * Document Head Script
	 *
	 * @var Document_Head_Script
	 */
	public $script;
		
	/**
	 * Document title
	 *
	 * @var script
	 */
	protected $title;
	
	/**
	 * Raw header html
	 *
	 * @var string
	 */
	protected $rawData;
		
	public function __construct(Lead_Controller_Response_Document $document)
	{
		parent::__construct($document);
				
		$this->meta = new Lead_Controller_Response_Document_Head_Meta($this);
		$this->style = new Lead_Controller_Response_Document_Head_Style($this);
		$this->script = new Lead_Controller_Response_Document_Head_Script($this);
		
		// $this->meta->add('content-type', "text/html; charset={$this->document->contentType()}", 1);
		// $this->meta->add('generator', 'LEAD Head Processor');		
		
	}
	
	
	/**
	 * Renders the document head.
	 *
	 * @return string
	 */
	public function render()
	{
		$output = array();
		$output[] = "<head>";
		$output[] = "<title>{$this->title}</title>";
		$output[] = $this->meta->render();
		$output[] = $this->style->render();
		$output[] = $this->script->render();
		$output[] = $this->rawData;
		$output[] = "</head>";
		return implode("\n", $output);
	}
	
	/**
	 * Sets title
	 *
	 * @param string $title
	 */
	public function setTitle($title)
	{
		$this->title = $title;
		
	}
	
	/**
	 * Returns title
	 *
	 * @return string
	 */
	public function getTitle()
	{
		return $this->title;
	}
	
	/**
	 * Appends something to body.
	 *
	 * @param string $to_append String to append
	 */
	function append($to_append)
	{
		$this->rawData .= $to_append;
				
	}
	
	/**
	 * Prepends something to body
	 *
	 * @param string $to_prepend String to prepend
	 */
	function prepend($to_prepend)
	{
		$this->rawData = $to_prepend . $this->body;
	}
	
	function set($to_set)
	{
		$this->rawData = $to_set;
		
	}
	
}
?>